/**
 * 
 */
package com.study.timer;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Administrator
 * @date 2019年4月27日
 */
public class ThreadTest {

	public static void main(String[] args) {

		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYY-MM-dd HH:MM:ss");

		Thread thread = new Thread(new Runnable() {

			@Override
			public void run() {
				while (true) {
					try {
						String strDate = simpleDateFormat.format(new Date());
						System.out.println("thread 实现定时器功能轮训。。。" + strDate);

						Thread.sleep(2000);
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}

				}
			}

		});

		thread.start();
	}
}
